## 指令
## 1. cmakelist同级目录下执行：cmake -S . -B build
## 2. cd build && cmake --build . --config Release
## 3. cmake --install . --config Release

cmake_minimum_required(VERSION 3.14)

# 工程名
set(PROJECT_NAME "cpp_tools")
project(${PROJECT_NAME} LANGUAGES CXX)

set(PLUGIN_NAME "cpp_tools")

# 资源文件
list(APPEND PLUGIN_SOURCES
)

# 生成动态库 只能用C导出
add_library(${PLUGIN_NAME} SHARED
        "cpp_tools.h"
        "cpp_tools.cpp"
        ${PLUGIN_SOURCES}
)
SET(CMAKE_BUILD_TYPE Release)

#版本自增
add_custom_target(
        update_version
        COMMAND ${CMAKE_COMMAND} -D GIT_VERSION=${GIT_VERSION} -P ${CMAKE_CURRENT_SOURCE_DIR}/update.cmake
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_dependencies(${PLUGIN_NAME} update_version)

set_target_properties(${PLUGIN_NAME} PROPERTIES
        CXX_VISIBILITY_PRESET hidden)

# 宏定义
target_compile_definitions(${PLUGIN_NAME} PRIVATE CPP_TOOLS_IMPL)

include_directories(
        "${CMAKE_CURRENT_SOURCE_DIR}/include"
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4819 -wd4996 -D__STDC_CONSTANT_MACROS -DWIN32_LEAN_AND_MEAN")

## 生成测试应用
set(TEST_RUNNER "${PLUGIN_NAME}_test")
add_executable(${TEST_RUNNER}
        test/main1.cpp
        ${PLUGIN_SOURCES}
)

target_include_directories(${TEST_RUNNER} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(${TEST_RUNNER} ${PLUGIN_NAME})

install(TARGETS ${PLUGIN_NAME} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/libs/")
